<html>
 <?php include 'dbInclude.php';?>
 <?php
  
   
	?>
  <head>
  <style>
a{

text-decoration:none;
}
  </style>
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="../css/wpl_style.css">
	<link rel="stylesheet" href="../css/bootstrap.min.css">
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
	<script>
$(document).ready(function(){
	$("#sub-content2").hide();
	$("#sub-content3").hide();
  $("#lua").click(function(){
	$("#sub-content1").show();
    $("#sub-content2").hide();
	$("#sub-content3").hide();
  });
  $("#ac").click(function(){
    $("#sub-content2").show();
    $("#sub-content1").hide();
	$("#sub-content3").hide();
  });
  $("#ct").click(function(){
    $("#sub-content3").show();
    $("#sub-content1").hide();
	$("#sub-content2").hide();
  });
  $("#butn2").click(function()
  {
	alert(this).parent().parent().find("clntname");
	alert("Hello");
	});	
});
</script>
     <script src="js/bootstrap.min.js"></script>
	
	<style>
	</style>
	
	</head>
	<body>
	<div class="container-fluid" id="container">
		<div id="header">
			<div id ="logo">
			<a href="../index.php">
			<img src="../images/PM9RTp1416879776.png"> </img>
			</a>
			</div>
			<div id ="headName">
			<div style="margin-left:0%;"><h3><span style="color:#A9D5FF;font-weight:bold;font-family:Arial;">Online Stock Market Trading</span></h3></div>
			<div style="margin-left:75%;margin-top:-3%;font-family : sans-serif;color :white;">
				<table style="color:white;"><tr><td>Hello, Admin</td></tr><tr><td ><a href="logout.php">Logout</a></td></tr>
				
				</table>
			</div>
			</div>
		</div>
			
			<div id="content">
				<div id="sub-content" style="height:70%;border-radius:10px;color:gray;text-decoration:none;">
					<table  width="100%" style="margin-top:10%;cursor : pointer;">
					<tr><td id="lua" style="text-align:center;"><a href="#">Link user accounts</a></td></tr>
					<tr><td>&nbsp;</td></tr>
					<tr><td id="ac" style="text-align:center;"><a href="#">Add company</a></td></tr>
					<tr><td>&nbsp;</td></tr>
					<tr><td id="ct" style="text-align:center;"><a href="#">Confirm trades</a></td></tr>
					</table>
					<!--
					<ul id="ulnone">
						<li id="lua"><a href="#">Link user accounts</a></li>
						<li id="ac"><a href="#">Add company</a></li>
						<li id="ct"><a href="#">Confirm trades</a></li>
					</ul>
					-->
				</div>
				<div id="sub-content1">
				<form role="form" action="./linkaccount.php" autocomplete="off" method="post" >
				<div id="dropdwn">
					<h3 style="margin-left:0px">Select and Link Following Accounts</h3>
					<label>
						<select id="slct" name="slct">
						<?php 
						$sql="SELECT CLIENT_ID FROM user_master WHERE CLIENT_ID NOT IN(SELECT CLIENT_ID FROM account_master WHERE CLIENT_ID IS NOT NULL)";
						$result=$dbh->query($sql);
						foreach($result as $row) {
						echo "<option>".$row["CLIENT_ID"]."</option>";
						}
						?>
						<option selected="selected">
						Select Client Id
						</option>
						</select>
					</label>
						
					<label>
						<select id="slct1" name="slct1">
						<?php 
						$sql="SELECT ACCOUNT_NUM FROM account_master WHERE CLIENT_ID is NULL";
						$result=$dbh->query($sql);
						foreach($result as $row) {
						echo "<option>".$row["ACCOUNT_NUM"]."</option>";
						}
						?>
						<option selected="selected">
						Select Account Id
						</option>
						</select>
					</label>
					</div>
					
					<div id="butn"><button type="submit" class="btn btn-info btn-block">Submit</button></div>
					</form>
				</div>
				<div id="sub-content2">
				<h3 align="center">Add new companies here</h3>
				<form role="form" action="./addCompany.php" autocomplete="off" method="post" >
					<div id="company_details">
						<label	>Enter company name:</label>
						<input type="text" name="company_name" class="form-control" id="company_name" placeholder="Enter name of the company"><br>
						<label>Describe the company:</label>
						<textarea cols="4" name="description" class="form-control" id="description" placeholder="Give brief description"></textarea><br>
						<label> Select the sector:</label><br>
						<select id="slct2" name="slct2">
							<?php 
								$sql="SELECT * FROM sector_master;";
								$result=$dbh->query($sql);
								foreach($result as $row)
								{
									echo $row["SECTOR_ID"];
									echo "<option value='".$row["SECTOR_ID"]."'>".$row["NAME"]."</option>";
								}
								?>
							
						</select>	
					</div>	
					
					<div id="butn1"><button type="submit" class="btn btn-info btn-block">Submit</button></div>
				</form>
				</div>
				<div id="sub-content3">
				
					<div id="order_details">
					<h3 align="center">Pending Orders</h3>
					<div id="fillref" class="CSSTableGenerator">
					<table>
						<tr>
								<th>Order ID</th>
								<th>Client name</th>
								<th>Last Name</th>
								<th>Company Name</th>
								<th>Quantity</th>	
								<th>LTP</th>
								<th>BUY/SELL</th>
								<th>Confirm??</th>
						</tr>
						
						<?php 
							$sql="SELECT ORDER_ID,FIRST_NAME,LAST_NAME,INSTR_NAME,QUANTITY,LTP,BUY_SELL FROM instrument_master I,user_master U,orders O WHERE I.INSTR_ID = O.INSTR_ID and O.CLIENT_ID = U.CLIENT_ID AND O.STATUS = 'P'";
							$result1=$dbh->query($sql);
							
							foreach($result1 as $row1) 
							{
								echo "<form role='form' action='./confirmOrders.php' autocomplete='off' method='get'>";
								//echo "<table border='2'>";
								echo "<tr>";
								echo "<td id='orderid'><input type='hidden' name='orderid' value='".$row1["ORDER_ID"]."'>".$row1["ORDER_ID"]."</td>"."<td>".$row1["FIRST_NAME"]."</td>"."<td>".$row1["LAST_NAME"]."</td>"."<td>".$row1["INSTR_NAME"]."</td>"."<td>".$row1["QUANTITY"]."</td>"."<td>".$row1["LTP"]."</td>";
								
								if($row1["BUY_SELL"]==1)
								{
									echo "<td>BUY</td>";
								}
								else
								{
									echo "<td>SELL</td>";
								}
								echo "<td><button type='submit' class='btn btn-info btn-block'>Approve</button>";
								
								echo "</tr>";
								//echo "</table>";
								echo "</form>";	
							}
						?>
					</table>
					</div>
					</div>
					
				</form>		
				</div>
			</div>
			
			<div class="footer_bg"><!-- start footer -->
			<div class="container">
				<div class="row  footer">
					<div class="copy text-center">
						<p class="link"><span>&#169; All rights reserved | Design by&nbsp;<a href="./about.html"> TEAM 11</a></span></p>
					</div>
				</div>
			</div>
	</div>
		
    </div>

    
  </body>
</html>
	
	